<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
        function Person(name, age) {
          this.name = name
          this.age = age
        }

        Person.prototype.say = function () {
          console.log(this.name)
        }

        function Student(name, age, score) {
          Person.call(this, name, age)
          this.score = score
        }
        Student.prototype = new Person()

      // class Person {
      //   constructor(name, age) {
      //     // 添加到实例上的属性,写在构造器中
      //     this.name = name
      //     this.age = age
      //   }
      //   // 添加到原型上的属性,写在类的结构体中
      //   say() {
      //     console.log(this.name)
      //   }
      // }

      // class Student extends Person {
      //   constructor(name, age, score) {
      //     super(name, age)
      //     this.score = score
      //   }
      // }

      // const s1 = new Student('zs', 18, 200)
      // console.log(s1)
      // s1.say()

      function fn() {
        console.log(this)
      }
      let obj = {
        xxx: fn,
      }
      // fn() // 普通调用==>window
      // 对象调用: ==>对象
      // 上下文调用: call, apply
      // obj.xxx()
      const newFn = fn.bind([123])
      newFn()
    </script>
  </body>
</html>
